import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:yysk_app/model/common_model/get_certification_type_model.dart';
import 'package:yysk_app/net/api/common_api.dart';
import 'package:yysk_app/net/http.dart';
import 'package:yysk_app/routes/global_controller.dart';

class SettingRealNameAuthController extends GetxController {
  final TextEditingController cardIdController = TextEditingController();
  final TextEditingController nameController = TextEditingController();
 final TextEditingController phoneController = TextEditingController();
  var isForever = false.obs;
  final infoDetail = Rx<GetCertificationTypeModel?>(null);
  
  @override
  void onInit() {
    super.onInit();
    getCertificationInfo();
  }

  Future<dynamic> getCertificationInfo() async {
    final res = http.netFetch<GetCertificationTypeModel>(
      CommonApi.getCertificationType,
      method: Method.post,
      success: (r) {
        infoDetail.value = r.data;
        nameController.text = infoDetail.value?.name ?? '';
        cardIdController.text = infoDetail.value?.cardId ?? '';
        final GlobalController globalController = Get.find();
        phoneController.text = globalController.user.value?.userTel ?? '';
        return r;
      },
    );
    return res;
  }

  @override
  void onClose() {
    cardIdController.dispose();
     nameController.dispose();
      phoneController.dispose();
    super.onClose();
  }

  void onChooseForever() {
    isForever.value = !isForever.value;
  }

}